<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html>
<body>
<%
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
      pageContext.setAttribute("user", user);
%>
<p>Hi, <%= user.getNickname() %>!</p>
<p>You can <a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>
(The action shall sign you out of all your google services).</p>
<%
    } else {
%>
<p>Hi!
<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
to gain full access to authorized API.</p>
<%
    }
%>
<p>Post
		<table border="1" cellpadding="1" cellspacing="1" style="width: 500px;">
			<thead>
				<tr>
					<th scope="col">
						Method</th>
					<th scope="col">
						HTTP request</th>
					<th scope="col">
						Description</th>
					<th scope="col">
						Parameters</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>
						get</td>
					<td>
						GET /posts/{id}</td>
					<td>
						get a post by id</td>
					<td>
						&nbsp;</td>
				</tr>
				<tr>
					<td>
						list</td>
					<td>
						GET /posts</td>
					<td>
						get list of posts</td>
					<td>
						author</td>
				</tr>
				<tr>
					<td>
						add</td>
					<td>
						POST /posts</td>
					<td>
						add a new post</td>
					<td>
						<p>
							title</p>
						<p>
							meta</p>
						<p>
							content</p>
					</td>
				</tr>
				<tr>
					<td>
						update</td>
					<td>
						PUT /post/{id}</td>
					<td>
						update a new post</td>
					<td>
						&nbsp;</td>
				</tr>
				<tr>
					<td>
						delete</td>
					<td>
						DELETE /posts/{id}</td>
					<td>
						delete a post by id</td>
					<td>
						&nbsp;</td>
				</tr>
			</tbody>
		</table>
		</p>
		<p>Comment
		<table border="1" cellpadding="1" cellspacing="1" style="width: 500px;">
			<thead>
				<tr>
					<th scope="col">
						Method</th>
					<th scope="col">
						HTTP request</th>
					<th scope="col">
						Description</th>
					<th scope="col">
						Parameters</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>
						get</td>
					<td>
						GET /posts/{pid}/comments/{cid}</td>
					<td>
						get a post&#39;s comment by id</td>
					<td>
						&nbsp;</td>
				</tr>
				<tr>
					<td>
						list</td>
					<td>
						GET /posts/{pid}/comments</td>
					<td>
						get list of comments of the post</td>
					<td>
						&nbsp;</td>
				</tr>
				<tr>
					<td>
						add</td>
					<td>
						POST /posts/{pid}/comments</td>
					<td>
						add a new comment for a post</td>
					<td>
						&nbsp;</td>
				</tr>
				<tr>
					<td>
						update</td>
					<td>
						PUT /post/{pid}/comments/{cid}</td>
					<td>
						update an existing post&#39;s comment</td>
					<td>
						&nbsp;</td>
				</tr>
				<tr>
					<td>
						delete</td>
					<td>
						DELETE /posts/{pid}/comments/{cid}</td>
					<td>
						delete a post&#39;s comment</td>
					<td>
						&nbsp;</td>
				</tr>
			</tbody>
		</table>
		</p>
</body>
</html>